package com.bdqn.blog.util;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {

    // 200成功，非200失败
    @ApiModelProperty("请求状态:200成功，非200失败")
    private int status;
    @ApiModelProperty("请求返回说明")
    private String msg;
    @ApiModelProperty("请求返回值")
    private Object data;


    public static Result success() {
        return Result.success("操作成功", null);
    }

    public static Result success(Object data) {
        return Result.success("操作成功", data);
    }

    public static Result success(String msg, Object data) {
        Result result = new Result();
        result.status = 200;
        result.msg = msg;
        result.data = data;
        return result;
    }

    public static Result fail(String msg) {
        Result result = new Result();
        result.status = 400;
        result.data = null;
        result.msg = msg;
        return result;
    }



}